package game.buildings;

/**
 *	@(#)MannableBuilding.java
 *
 *	The <code>MannableBuilding</code> class represents
 *	an abstract mannable building.
 *
 *	@author Grzegorz Kobiela
 *	@version 1.0 2008/4/23
 */
public abstract class MannableBuilding
extends CityBuilding
implements Mannable
{
	/** The worker. */
	protected game.Worker worker;

	/**
	 *	Creates a new <code>MannableBuilding</code> instance.
	 *	@param type the building type
	 */
	protected MannableBuilding(BuildingType type) {
		super(type);
		worker = null;
	}

	/**
	 *	Sets the worker.
	 *	@param worker the worker
	 */
	public void setWorker(game.Worker worker) {
		game.Worker previous = this.worker;
		this.worker = worker;
		update(worker != null ? worker : previous);
	}

	/**
	 *	Returns the worker.
	 *	@return the worker
	 */
	public game.Worker getWorker() {
		return worker;
	}

	/**
	 *	Returns true if the building is manned.
	 *	@return true if the building is manned
	 */
	public boolean isManned() {
		return (worker != null);
	}
}